self.addEventListener('fetch', (event) => {
  event.respondWith((async () => {
    const res = await fetch(event.request)
    const reader = res.body.getReader()
    const stream = new ReadableStream({
      start(controller) {
        const sleep = time => new Promise(resolve => setTimeout(resolve, time));
        const streamHandle = async () => {
          const { value, done } = await reader.read()
          if (done) {
            controller.close()
            console.log('event--->', event.request)
            return
          }
          const length = value.length
          for (let i = 0; i < length; i++) {
            await sleep(30)
            controller.enqueue(value.slice(i, i+1))
          }
          streamHandle()
        }
        streamHandle()
      }
    })
    return new Response(stream, { headers: res.headers })
  })())
})